from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _


# Create your models here.

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    reward = models.IntegerField(_('Reward Point'), default=0, edit_able=False)
    efficiency = models.FloatField(_('Efficiency'), default=0, edit_able=False)
    arguments = models.IntegerField(_('arguments'), default=0, edit_able=False)
    debates = models.IntegerField(_('debates'), default=0, edit_able=False)
    
    about_me = models.TextField(_('About me'), blank=True)
    pic = models.CharField(_('pic'), blank=True)
    
    def __unicode__(self):
        return self.user
    
    class Meta:
        verbose_name = _('UserProfile')
        db_table = 'user_profile'
        
    
class UserIMs(models.Model):
    user = models.ForeignKey(User)
    type = models.IntegerField(_('IM Type'), choices=((0, 'QQ'), (1, 'MSN')))
    account = models.CharField(_('IM Account'), max_length=100)
    
    def __unicode__(self):
        return self.account
    
    class Meta:
        verbose_name = _('ims')
        db_table = 'user_ims'
    
class UserLinks(models.Model):
    user = models.ForeignKey(User)
    title = models.CharField(_('link title'), max_length=200)
    url = models.URLField(_('link url'), max_length=200)
    
    def __unicode__(self):
        return self.url
    
    class Meta:
        verbose_name = _('user links')
        db_table = 'user_links'



class UserRelation(models.Model):
    user1 = models.ForeignKey(User)
    user2 = models.ForeignKey(User)
    relation = models.IntegerField(_('relation'), choices=((0, _('Allies')), (1, _('Enemies')), (2, _('Hostiles'))))
    
    def __unicode__(self):
        return self.relation
    
    class Meta:
        verbose_name = _('user relation')
        db_table = 'user_relation'
        

class UserConversations(models.Model):
    user = models.ForeignKey(User)
    postuser = models.ForeignKey(User)
    content = models.TextField(_('content'))
    
    def __unicode__(self):
        return self.content
    
    class Meta:
        verbose_name = _('User Conversations')
        db_table = 'user_conversations'
        

class UserPoint(models.Model):
    user = models.ForeignKey(User)
    point = models.IntegerField(_('Point'))
    when = models.DateTimeField(_('when'), auto_now_add=True)
    what = models.IntegerField(_('what'), choices=((0, _('Added Argument')), (1, _('create debate'))))
    content_type = models.ForeignKey(ContentType)
    object_id = models.IntegerField()
    where = models.GenericForeignKey()
    
    def __unicode__(self):
        return self.point
    
    class Meta:
        verbose_name = _('User Point')
        db_table = 'user_point'
    
    
    